package features;

import javax.swing.tree.DefaultMutableTreeNode;

import operationSolids.CompoundSolid;
import operationSolids.OperationPlanarFace;
import CAD.MainFrame;

public class PlanarFace extends Feature{

	Boss boss;
	double depth;
	
	public PlanarFace(int type, Feature Mother, 
			float posx, float posy, float posz,
			float depth, String name,int face) {
		super(type, Mother, name);
		this.depth=depth;
		feature = new OperationPlanarFace(name,depth,face);
		//boss = new Boss(); implemnetar
		create(posx,posy,posz,face);
		MainFrame.features.add(this);
		MainFrame.refreshJTree();
	}

	@Override
	void compound() {
		MainFrame.block  = new Block ("comp",CompoundSolid.DIFFERENCE,MainFrame.block,feature);
	}

	@Override
	void translate() {
		feature.translate(placement.getX(), placement.getZ() - depth/2,placement.getY() );
		switch (MainFrame.Face) {
		case MainFrame.BACKFACE:
			feature.translate(0, MainFrame.block.length/2,0);
			break;
		case MainFrame.FRONTFACE:
			feature.translate(0, MainFrame.block.length/2,0);
			break;
		case MainFrame.EASTFACE:
			feature.translate(0,MainFrame.block.width/2,0);
			break;
		case MainFrame.WESTFACE:
			feature.translate(-0,MainFrame.block.width/2,0 );
			break;
		case MainFrame.LOWERFACE:
			feature.translate(0, MainFrame.block.height/2,0);
			break;
		case MainFrame.TOPFACE:
			feature.translate(0, MainFrame.block.height/2,0);
			break;

		default:
			System.out.println("erro");
			break;
		}
	}

	@Override
	public void drawNode(DefaultMutableTreeNode node) {
		node.add(
				new DefaultMutableTreeNode(
				"Depth:"+depth+"mm")
				);
	}

}
